/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean.session;

import entity.RawMaterialPurchaseOrderEntity;
import entity.RawMaterialPurchaseOrderReportEntity;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author wei
 */
@Stateless
public class RawMaterialPurchaseOrderReportEntityFacade extends AbstractFacade<RawMaterialPurchaseOrderReportEntity> {

    @PersistenceContext(unitName = "MacTeam-warPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public RawMaterialPurchaseOrderReportEntityFacade() {
        super(RawMaterialPurchaseOrderReportEntity.class);
    }

    public RawMaterialPurchaseOrderReportEntity findReport(RawMaterialPurchaseOrderReportEntity check) {
        List<RawMaterialPurchaseOrderReportEntity> list = this.findAllIncludeArchived();
        for (RawMaterialPurchaseOrderReportEntity l : list) {
            if(l.getProduct()!=null)
            if ((l.getProduct().equals(check.getProduct()) && (l.getExpectedMonthOfRecepit().equals(check.getExpectedMonthOfRecepit()) && (l.getExpectedWeekOfReceipt() == check.getExpectedWeekOfReceipt()) && (l.getExpectedYearOfReceipt() == check.getExpectedYearOfReceipt())))) {
                return l;
            }
        }
        return null;
    }
}
